#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
#TODO: documentation!
"""

__version__ = '$Id: scene.py 196 2008-03-04 03:10:05Z DLacewell $'


from bipy.util import _get_class

class Scene(object):
    """
    BaseState includes the basic functionality of the application. 
    -   Events are passed to the state, blindly, and can be handled if desired
        by adding an entry in the function matrix and providing a handling method.
    """
    def __init__(self, engine):
        self.engine = engine
        
    def get_signal_matrix(self):
        """
        A hard-coded map of signal-type to listening handle method
        """
        return {
            'render' : self.render
            }

    def enter(self):
        """
        Called after State registers with the stack.
        """
        pass
    
    def leave(self):
        """
        Called before State unregisters with the stack.
        """
        pass
        
    def render(self):
        self.engine.screen.clear()
    

_loaded_scene_classes = {} 

def get( scene_name ):
    if scene_name in _loaded_scene_classes:
        return _loaded_scene_classes[ scene_name ]
    full_path = '.'.join( [__name__, scene_name, 'scene_class'] )
    cls = _get_class(full_path, parentClass=Scene)
    if cls:
        _loaded_scene_classes[ scene_name ] = cls
        return cls
    else:
        return None